package OutputStream;

import java.io.*;

/**
 * @author 王艺锡
 * @version 1.0
 * 字节流->以二进制的方式读写，可用于拷贝视频，图片等
 * BufferedInputStream和BufferedOutputStream的使用
 */
public class BufferCopy02_ {
    public static void main(String[] args){
        //拷贝图片
        String srcFilePath = "e:\\image.png";
        String destFilePath = "e:\\image02.png";
        BufferedInputStream bis = null;
        BufferedOutputStream bos = null;

        try {
            bis = new BufferedInputStream(new FileInputStream(srcFilePath));
            bos = new BufferedOutputStream(new FileOutputStream(destFilePath));
            byte buf[] = new byte[999];
            int readLen = 0;
            while ((readLen = bis.read(buf)) != -1){
                bos.write(buf,0,readLen);
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {

            try {
                bis.close();
                bos.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }


    }
}
